package com.bt.service.impl;

import com.alibaba.druid.util.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bt.mapper.DtsCommentMapper;
import com.bt.pojo.DtsComment;
import com.bt.service.DtsCommentSerive;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author wbt
 * @version v1.0
 * @project shop_manage
 * @data 2022/9/24 11:30
 **/
@Service
public class DtsCommentSeriveImpl implements DtsCommentSerive {
    @Autowired
    private DtsCommentMapper dtsCommentMapperImpl;
    @Override
    public IPage<DtsComment> findCommentByPage(Integer page, Integer limit, Integer userId, Integer valueId, String sort, String order) {
        return dtsCommentMapperImpl.selectPage(new Page<DtsComment>(page,limit),new QueryWrapper<DtsComment>().eq(userId!=null,"user_id",userId).eq(valueId!=null,"value_id",valueId).orderBy(!StringUtils.isEmpty(sort),"asc".equalsIgnoreCase(order),sort));
    }

    @Override
    public void deleteComment(DtsComment dtsComment) {
        dtsCommentMapperImpl.deleteById(dtsComment);
    }
}
